package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.Nullable;
import com.huawei.appgallery.agreement.api.ui.ITermsActivityProtocol;
import com.huawei.appgallery.agreement.api.ui.IUpgradeActivityProtocol;
import com.huawei.appgallery.agreement.api.ui.TermsActivityProtocol;
import com.huawei.hmf.annotation.ApiDefine;
import com.huawei.hmf.annotation.Singleton;
import com.huawei.secure.android.common.intent.SafeIntent;

@ApiDefine(uri = awm.class)
@Singleton
public class axi implements awm {
    private static int ॱ = 0;

    public static void ˋ(int i) {
        awg.ˎ.ˋ("AgreementManager", "setPendingAction: " + ॱ + " -> " + i);
        ॱ = i;
    }

    public boolean ˏ() {
        return ayn.ʻ();
    }

    public boolean ˋ() {
        return ayn.ˏॱ();
    }

    public void ˋ(String str, boolean z) {
        ayn.ˎ(str, z);
    }

    public void ॱ(String str, boolean z) {
        ayn.ॱ(str, z);
    }

    public void ˏ(String str, boolean z) {
        ayn.ˏ(str, z);
    }

    public void ˊ(boolean z, @Nullable awl o_awl) {
        if (!z) {
            ayn.ˋ(true);
        }
        ayf o_ayf = new ayf(z);
        o_ayf.ॱ(o_awl);
        o_ayf.ˊ();
    }

    public void ˎ(Context context, awj o_awj) {
        ContentManager.build(context);
        axg.ˋ(o_awj);
    }

    public boolean ˊ() {
        return ayn.ॱॱ();
    }

    public void ˎ() {
        ayn.ॱ();
    }

    public void ˋ(@Nullable awl o_awl) {
        ˊ(false, o_awl);
    }

    public void ˊ(Activity activity, awt o_awt) {
        ˏ(activity, false, o_awt);
    }

    public void ˏ(Activity activity, boolean z, awt o_awt) {
        if (ॱ == 2) {
            ॱ(activity, o_awt);
            return;
        }
        ˋ(0);
        if (ccx.ॱ()) {
            awg.ˎ.ˋ("AgreementManager", "showProtocolDialog2 skipped, already signed");
            o_awt.ॱ(true);
            return;
        }
        String str = getClass().getName() + activity.hashCode();
        aya.ˎ().ˎ(str, new d(o_awt, str, null));
        fjb ॱ = bkt.ॱ("Agreement", "AgreementSignActivity");
        ITermsActivityProtocol iTermsActivityProtocol = (ITermsActivityProtocol) ॱ.ˊ();
        iTermsActivityProtocol.setViewType(ॱ(activity));
        iTermsActivityProtocol.setSignForUser(z);
        iTermsActivityProtocol.setDialogId(str);
        fiu.ˊ().ˏ(activity, ॱ);
    }

    public void ˋ(Activity activity, awt o_awt) {
        ˎ(activity, false, o_awt);
    }

    public void ˎ(Activity activity, boolean z, awt o_awt) {
        if (ॱ == 2) {
            ॱ(activity, o_awt);
            return;
        }
        ˋ(0);
        if (ccx.ॱ()) {
            awg.ˎ.ˋ("AgreementManager", "showProtocolDialog skipped, already signed");
            o_awt.ॱ(true);
            return;
        }
        int ॱ = ॱ(activity);
        ITermsActivityProtocol termsActivityProtocol = new TermsActivityProtocol();
        termsActivityProtocol.setViewType(ॱ);
        termsActivityProtocol.setSignForUser(z);
        aym.ॱ(activity, termsActivityProtocol, o_awt);
    }

    private static int ॱ(Activity activity) {
        return ˋ(activity, "view_type", 0);
    }

    private static int ˋ(Activity activity) {
        return ˋ(activity, "service_type", 0);
    }

    private static int ˋ(Activity activity, String str, int i) {
        Intent intent = activity.getIntent();
        if (intent == null) {
            return i;
        }
        int intExtra = new SafeIntent(intent).getIntExtra(str, i);
        try {
            intent.putExtra(str, i);
        } catch (Exception e) {
            awg.ˎ.ˊ("AgreementManager", "putExtra exception = " + e);
        }
        activity.setIntent(intent);
        return intExtra;
    }

    public void ˊ(Activity activity) {
        aym.ˊ(activity);
    }

    public void ॱ() {
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(new Intent("com.huawei.appmarket.close.tips.protocol"));
    }

    public void ˏ(Activity activity, awn o_awn, awo o_awo) {
        new ayg(activity, o_awn, o_awo).ˋ();
    }

    public boolean ʼ() {
        return ॱ != 0;
    }

    public void ॱ(Activity activity, awt o_awt) {
        ˋ(0);
        if (ccx.ॱ()) {
            awg.ˎ.ˋ("AgreementManager", "showUpgradeDialog skipped, already signed");
            o_awt.ॱ(true);
            return;
        }
        String str = getClass().getName() + activity.hashCode();
        aya.ˎ().ˎ(str, new d(o_awt, str, null));
        fjb ॱ = bkt.ॱ("Agreement", "AgreementUpgradeActivity");
        int ॱ2 = ॱ(activity);
        int ˋ = ˋ(activity);
        IUpgradeActivityProtocol iUpgradeActivityProtocol = (IUpgradeActivityProtocol) ॱ.ˊ();
        iUpgradeActivityProtocol.setViewType(ॱ2);
        iUpgradeActivityProtocol.setServiceType(ˋ);
        iUpgradeActivityProtocol.setDialogId(str);
        fiu.ˊ().ˏ(activity, ॱ);
    }
}
